home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / turlvi17.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  3.3 KB  |  119 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TURLView
  4. //    Include File:    turlview.h
  5. //    Purpose:    Provide the view of a URL
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-27-93    created
  9. //        02-02-94    Began a major revision to fully handle a
  10. //                multiple document interface with WWW, take
  11. //                over the formatting and drawing of the
  12. //                old gridtext functions of HText, and optimize
  13. //                memory usage, selecting anchors, the usage of
  14. //                HText's new image file.  See gridtext.
  15. //        02-09-94    Split all members into seperate files.
  16. #include"turlview.h"
  17. #include"trace.h"
  18. #include<string.h>
  19.  
  20. void TURLView::LoadChild()    {
  21. //    Purpose:    Cause the load of the selected child anchor.
  22. //    Arguments:    void
  23. //    Return Value:    void
  24. //    Remarks/Portability/Dependencies/Restrictions:
  25. //        Puts an event into the event queue such that the following
  26. //        actions should be taken by the owner of the TURLView:
  27. //            destroy the TURLView
  28. //            load the child anchor in the TURLView's place.
  29. //    Revision History:
  30. //        01-30-94    created
  31. //        04-06-94    Modified to not load if it is a tagged anchor
  32. //                and we are the same document.  Will instead
  33. //                search for the named anchor and scrollTo
  34. //                it's position.
  35.  
  36.     //    Figure out this view's url and the selected anchor's url.
  37.     auto char *cp_thisURL = getURL();
  38.     auto char *cp_childURL = getChild();
  39.  
  40.     //    If the child goes nowhere, can't select.
  41.     if(cp_childURL == NULL)    {
  42.         return;
  43.     }
  44.  
  45.     //    Find out if the child has a tag.
  46.     auto char *cp_startTag;
  47.     if((cp_startTag = strchr(cp_childURL, '#')) != NULL)    {
  48.         //    Compare the two, if same, assume named anchor.
  49.         if(strncmp(cp_thisURL, cp_childURL, (int)(cp_startTag -
  50.             cp_childURL)) == 0)    {
  51.             //    Assume it is a tag.
  52.             //    Seek out it's location and scroll to it if
  53.             //    possible.
  54. #ifndef RELEASE
  55.             trace("Tagged anchor within this document.");
  56. #endif // RELEASE
  57.             //    Advance past the '#'
  58.             cp_startTag++;
  59.  
  60.             //    Go through the list of anchors comparing
  61.             //    tags.
  62.             auto TextAttribute *TAp_looking;
  63.             for(auto unsigned short int usi_counter = 0U;
  64.                 usi_counter < TNSCp_anchors->getCount();
  65.                 usi_counter++)    {
  66.                 TAp_looking = (TextAttribute *)
  67.                     (TNSCp_anchors->at(usi_counter));
  68.  
  69.                 //    Continue on if the tag is empty.
  70.                 if(TAp_looking->HTCAp_anchor->tag == NULL)
  71.                 {
  72.                     continue;
  73.                 }
  74.  
  75.                 if(strcmp(TAp_looking->HTCAp_anchor->tag,
  76.                     cp_startTag) == 0)    {
  77.                     //    Found.
  78.                     TAp_selected = TAp_looking;
  79.                     AnchorInView();
  80.  
  81.                     //    Fudge the history list of the
  82.                     //    window.
  83.                     /*    Taken out for alpha release.
  84.                     auto TEvent TE_fudge;
  85.                     TE_fudge.what = evCommand;
  86.                     TE_fudge.message.command =
  87.                         cmAddToHist;
  88.                     TE_fudge.message.infoPtr = (void *)
  89.                         cp_startTag;
  90.                     putEvent(TE_fudge);
  91.                     */
  92.  
  93.                     //    Done.
  94.                     delete(cp_childURL);
  95.                     return;
  96.                 }
  97.             }
  98.             //    Tag not found.  Just continue on with an
  99.             //    attempt to load.
  100.         }
  101.     }
  102.  
  103.     //    Free the child url, allocated in other code by a call to
  104.     //    getChild();
  105.     delete(cp_childURL);
  106.  
  107.     auto TEvent TE_load;
  108.  
  109.     //    Set up the event.
  110.     //    Make sure to somehow mark which TURLView to destory through
  111.     //        this message.
  112.     TE_load.what = evCommand;
  113.     TE_load.message.command = cmLoadChild;
  114.     TE_load.message.infoPtr = (void *)this;
  115.  
  116.     //    Output the message.
  117.     putEvent(TE_load);
  118. }
  119.